/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import fr.eisti.icc.data.Document;

import fr.eisti.icc.data.Emprunt;
import fr.eisti.icc.data.Reservation;

import java.util.List;
import javax.ws.rs.core.MultivaluedMap;

/**
 * Jersey REST client generated for REST resource:BibliothequeFacadeREST
 * [fr.eisti.icc.data.bibliotheque]<br> USAGE:
 * <pre>
 *        clientbibliotheque client = new clientbibliotheque();
 *        Object response = client.XXX(...);
 *        // do whatever with response
 *        client.close();
 * </pre>
 *
 * @author clion
 */
public class ClientBibliotheque {

    private WebResource webResource;
    private WebResource webResourceDocument;
    private WebResource webResourceEmprunteur;
    private Client client;
    private static final String BASE_URI = "http://192.168.129.7:8040/WebApplication2/webresources";

    public ClientBibliotheque() {
        com.sun.jersey.api.client.config.ClientConfig config = new com.sun.jersey.api.client.config.DefaultClientConfig();
        client = Client.create(config);
        webResource = client.resource(BASE_URI).path("fr.eisti.icc.data.bibliotheque");
        webResourceDocument = client.resource(BASE_URI).path("fr.eisti.icc.data.document");
        webResourceEmprunteur = client.resource(BASE_URI).path("fr.eisti.icc.data.Emprunteur");
    }

    public void remove(String id) throws UniformInterfaceException {
        webResource.path(java.text.MessageFormat.format("{0}", new Object[]{id})).delete();
    }

    public void create_XML(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.APPLICATION_XML).post(requestEntity);
    }

    public void create_JSON(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.APPLICATION_JSON).post(requestEntity);
    }

    public ClientResponse supprimerDocument_XML(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
    }

    public ClientResponse supprimerDocument_JSON(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
    }

    public void editDocument_XML(Object requestEntity) throws UniformInterfaceException {
        webResourceDocument.type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(requestEntity);
    }

    public void editDocument_JSON(Object requestEntity) throws UniformInterfaceException {
        webResourceDocument.type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(requestEntity);
    }

    public ClientResponse preterDocument_XML(String idDocument, String loginClient,  String chequeCaution) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
       
        formData.add("chequeCaution", chequeCaution);
        WebResource resource = webResource;
        resource = resource.path("preterDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse reserverDocument_XML(String idDocument, String loginClient) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        WebResource resource = webResource;
        resource = resource.path("reserverDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse reserverDocument_JSON(String idDocument, String loginClient) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        WebResource resource = webResource;
        resource = resource.path("reserverDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse annulerReservation_XML(String idDocument) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        WebResource resource = webResource;
        resource = resource.path("annulerReservation");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse annulerReservation_JSON(String idDocument) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        WebResource resource = webResource;
        resource = resource.path("annulerReservation");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse documentEstReserve_XML(String idDocument) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        WebResource resource = webResource;
        resource = resource.path("documentEstReserve");
        resource = resource.queryParams(formData);
        return resource.get(ClientResponse.class);
    }
    
    public ClientResponse documentEstReserve_JSON(String idDocument) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        WebResource resource = webResource;
        resource = resource.path("documentEstReserve");
        resource = resource.queryParams(formData);
        return resource.get(ClientResponse.class);
    }
    
    public List<Reservation> getListeReservationEmprunteur_XML(String login) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.queryParam("login", login);
        resource = resource.path("getListeReservationEmprunteur");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get((new GenericType<List<Reservation>>() { }));
        
    }
    
    public List<Reservation> getListeReservationEmprunteur_JSON(String login) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.queryParam("login", login);
        resource = resource.path("getListeReservationEmprunteur");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get((new GenericType<List<Reservation>>() { }));
        
    }
    
    public List<Reservation> getListeReservation_XML() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getListeReservation");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get((new GenericType<List<Reservation>>() { }));
        
    }
    
    public List<Reservation> getListeReservation_JSON() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getListeReservation");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get((new GenericType<List<Reservation>>() { }));
        
    }
    
    public ClientResponse getListeReservationEmprunteur_XML(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
    }

    public ClientResponse getListeReservationEmprunteur_JSON(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
    }
    
    public ClientResponse getListeReservation_XML(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
    }

    public ClientResponse getListeReservation_JSON(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerDocument").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
    }
    
    public List<Emprunt> getListePretsUtilisateur_XML() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getListePretsUtilisateur");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get((new GenericType<List<Emprunt>>() { }));
        
    }
    
    public List<Emprunt> getListePretsUtilisateur_JSON(String login) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.queryParam("login", login);
        resource = resource.path("getListePretsUtilisateur");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get((new GenericType<List<Emprunt>>() { }));
        
    }
    
    public ClientResponse getImage(String nomFichier) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("nomFichier", nomFichier);
        WebResource resource = webResource;
        resource = resource.path("getImage");
        resource = resource.queryParams(formData);
        return resource.get(ClientResponse.class);
    }

    public ClientResponse preterDocument_JSON(String idDocument, String loginClient,  String chequeCaution) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
       
        formData.add("chequeCaution", chequeCaution);
        WebResource resource = webResource;
        resource = resource.path("preterDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }
    
    public ClientResponse preterDocumentDuree_XML(String idDocument, String loginClient,  String chequeCaution, String day) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        
        formData.add("chequeCaution", chequeCaution);
        formData.add("day", day);
        WebResource resource = webResource;
        resource = resource.path("preterDocumentDuree");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }

    public ClientResponse preterDocumentDuree_JSON(String idDocument, String loginClient, String chequeCaution, String day) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        
        formData.add("chequeCaution", chequeCaution);
        formData.add("day", day);
        WebResource resource = webResource;
        resource = resource.path("preterDocumentDuree");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }

    public ClientResponse recupererDocument_XML(String idDocument, String loginClient) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        WebResource resource = webResource;
        resource = resource.path("recupererDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class);
    }

    public ClientResponse recupererDocument_JSON(String idDocument, String loginClient) throws UniformInterfaceException {
        MultivaluedMap formData = new MultivaluedMapImpl();
        formData.add("idDocument", idDocument);
        formData.add("loginClient", loginClient);
        WebResource resource = webResource;
        resource = resource.path("recupererDocument");
        resource = resource.queryParams(formData);
        return resource.put(ClientResponse.class, formData);
    }

    public ClientResponse addDocument_XML(Object requestEntity) throws UniformInterfaceException, InstantiationException, IllegalAccessException {
      
            return webResource.path("addDocument").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
        
    }

    public ClientResponse addDocument_JSON(Object requestEntity) throws UniformInterfaceException, InstantiationException, IllegalAccessException {
      
            return webResource.path("addDocument").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
        
    }

    public void addBlackList_XML(Object requestEntity) throws UniformInterfaceException {
        webResource.path("addBlackList").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(requestEntity);
    }

    public void addBlackList_JSON(Object requestEntity) throws UniformInterfaceException {
        webResource.path("addBlackList").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(requestEntity);
    }

    public void supprimerBlackList_XML(Object requestEntity) throws UniformInterfaceException {
        webResource.path("supprimerBlackList").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(requestEntity);
    }
    
    public void supprimerBlackList_JSON(Object requestEntity) throws UniformInterfaceException {
        webResource.path("supprimerBlackList").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(requestEntity);
    }

    public <T> T findRange_XML(Class<T> responseType, String from, String to) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new Object[]{from, to}));
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T findRange_JSON(Class<T> responseType, String from, String to) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new Object[]{from, to}));
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public <T> T getClientBlackList_XML(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getClientBlackList");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getClientBlackList_JSON(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getClientBlackList");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public <T> T getClients_XML(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getClients");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getClients_JSON(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getClients");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public <T> T getClientByLogin_XML(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (id != null) {
            resource = resource.queryParam("id", id);
        }
        resource = resource.path("getClientByLogin");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getClientByLogin_JSON(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (id != null) {
            resource = resource.queryParam("id", id);
        }
        resource = resource.path("getClientByLogin");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public <T> T getClientByName_XML(Class<T> responseType, String prenom, String nom) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (prenom != null) {
            resource = resource.queryParam("prenom", prenom);
        }
        if (nom != null) {
            resource = resource.queryParam("nom", nom);
        }
        resource = resource.path("getClientByName");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getClientByName_JSON(Class<T> responseType, String prenom, String nom) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (prenom != null) {
            resource = resource.queryParam("prenom", prenom);
        }
        if (nom != null) {
            resource = resource.queryParam("nom", nom);
        }
        resource = resource.path("getClientByName");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public <T> T find_XML(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path(java.text.MessageFormat.format("{0}", new Object[]{id}));
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T find_JSON(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path(java.text.MessageFormat.format("{0}", new Object[]{id}));
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public ClientResponse addEmprunteur_XML(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("addEmprunteur").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
    }

    public ClientResponse addEmprunteur_JSON(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("addEmprunteur").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
    }
    
    public ClientResponse supprimerEmprunteur_XML(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerEmprunteur").type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(ClientResponse.class, requestEntity);
    }
    
    public ClientResponse supprimerEmprunteur_JSON(Object requestEntity) throws UniformInterfaceException {
        return webResource.path("supprimerEmprunteur").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(ClientResponse.class, requestEntity);
    }
    
    public void editEmprunteur_XML(Object requestEntity) throws UniformInterfaceException {
  
              webResourceEmprunteur = client.resource(BASE_URI).path("fr.eisti.icc.data.Emprunteur");
          
        webResourceEmprunteur.type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(requestEntity);
    }

    public void editEmprunteur_JSON(Object requestEntity) throws UniformInterfaceException {
 
              webResourceEmprunteur = client.resource(BASE_URI).path("fr.eisti.icc.data.Emprunteur");
          
        webResourceEmprunteur.type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(requestEntity);
    }

    public String countREST() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("count");
        return resource.accept(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
    }

    public <T> T findAll_XML(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T findAll_JSON(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public List<Document> getDocuments_XML(String type, String motscle) throws UniformInterfaceException {
        WebResource resource = webResource;

        resource = resource.queryParam("type", type);
        resource = resource.queryParam("motscle", motscle);

        resource = resource.path("getDocuments");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(new GenericType<List<Document>>() {
        });
    }

    public List<Document> getDocuments_JSON(String type, String motscle) throws UniformInterfaceException {
        WebResource resource = webResource;

        resource = resource.queryParam("type", type);
        resource = resource.queryParam("motscle", motscle);

        resource = resource.path("getDocuments");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(new GenericType<List<Document>>() {
        });
    }

    public List<Document> getDocumentsByMap_XML(String type, String map) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.queryParam("type", type);
        resource = resource.queryParam("motscle", map);
        resource = resource.path("getDocumentsByMap");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get((new GenericType<List<Document>>() {
        }));
    }

    public List<Document> getDocumentsByMap_JSON(String type, String map) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.queryParam("type", type);
        resource = resource.queryParam("motscle", map);
        resource = resource.path("getDocumentsByMap");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get((new GenericType<List<Document>>() {
        }));
    }

    public void edit_XML(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.APPLICATION_XML).put(requestEntity);
    }

    public void edit_JSON(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(requestEntity);
    }

    public List<Document> getAllDocuments_XML( String type) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (type != null) {
            resource = resource.queryParam("type", type);
        }
        resource = resource.path("getAllDocuments");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get((new GenericType<List<Document>>() { }));
    }

    public List<Document> getAllDocuments_JSON( String type) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (type != null) {
            resource = resource.queryParam("type", type);
        }
        resource = resource.path("getAllDocuments");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get((new GenericType<List<Document>>() { }));
    }

    public <T> T getInstance_XML(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getBibliotheque");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getInstance_JSON(Class<T> responseType) throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getBibliotheque");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public List<Emprunt> getListePrets_XML() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getListePrets");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(new GenericType<List<Emprunt>>() {});
    }

    public List<Emprunt> getListePrets_JSON() throws UniformInterfaceException {
        WebResource resource = webResource;
        resource = resource.path("getListePrets");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(new GenericType<List<Emprunt>>() {});
    }

    public <T> T getDocumentsById_XML(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (id != null) {
            resource = resource.queryParam("id", id);
        }
        resource = resource.path("getDocumentsById");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
    }

    public <T> T getDocumentsById_JSON(Class<T> responseType, String id) throws UniformInterfaceException {
        WebResource resource = webResource;
        if (id != null) {
            resource = resource.queryParam("id", id);
        }
        resource = resource.path("getDocumentsById");
        return resource.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
    }

    public void close() {
        client.destroy();
    }
}